package sol.leetcode;

/**
 * Best Time to Buy and Sell Stock II
 */
public class Issue122 {
    public int maxProfit(int[] prices) {
        int sum = 0;
        for (int i = 1; i < prices.length; ++i) {
            int delta = prices[i] - prices[i - 1];
            sum += delta > 0 ? delta : 0;
        }
        return sum;
    }

    public static void main(String[] args) {
        int[] nums = {1, 2, 3, 4, 5};
        System.out.println(new Issue122().maxProfit(nums));
    }
}
